/**
 * 测试task接口代码
 *
 * @author bian
 * @createDate 2016.8.27
 */

// library module
var co = require("co");

// my module
var Task = require("./index");

// my config
var config = require("./config.json");
var pkg = require("../package.json");
var sceneId = pkg.scene_id;
var appId = config.appId;
var appSecret = config.appSecret;
var testAppId = config.testAppId;
var testAppSecret = config.testAppSecret;

var task = new Task(testAppId,testAppSecret);

co(function *(){
    yield task.refreshAccessToken();

    var accessToken = yield task.getAccessToken();
    console.log("accessToken",accessToken);

    var openIdArr = yield task.getUserList();
    var openId;
    for(openId of openIdArr){
        yield task.getUserInfo(openId);
    }

    var users = yield task.getAllUsersInfo();
    console.log("users",users);

    var qrCodeUrl = yield task.getQrCode(sceneId,true);
    console.log("qrCodeUrl",qrCodeUrl);

    process.exit(0);
}).catch(function(err){
    console.log(err);
});